<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>30-代理捕获器与反射方法 | 小黑博客</title><meta name="keywords" content="JavaScript,JavaScript高级程序设计第四版"><meta name="author" content="BluesYoung-web"><meta name="copyright" content="BluesYoung-web"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="get(target, propName, reciver) 参数说明： target——‘原始对象’ propName——‘属性名’ reciver——‘调用时的对象(.左边的)’   获取属性值时调用 返回值无限制 拦截的操作： proxy.property proxy[property] Object.create(proxy)[property] Reflect.get(proxy, pr">
<meta property="og:type" content="article">
<meta property="og:title" content="30-代理捕获器与反射方法">
<meta property="og:url" content="https://bluesyoung-web.gitee.io/blog/2021-01-13-30-%E4%BB%A3%E7%90%86%E6%8D%95%E8%8E%B7%E5%99%A8%E4%B8%8E%E5%8F%8D%E5%B0%84%E6%96%B9%E6%B3%95.html">
<meta property="og:site_name" content="小黑博客">
<meta property="og:description" content="get(target, propName, reciver) 参数说明： target——‘原始对象’ propName——‘属性名’ reciver——‘调用时的对象(.左边的)’   获取属性值时调用 返回值无限制 拦截的操作： proxy.property proxy[property] Object.create(proxy)[property] Reflect.get(proxy, pr">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://bluesyoung-web.gitee.io/blog/img/hbs.png">
<meta property="article:published_time" content="2021-01-13T03:43:53.000Z">
<meta property="article:modified_time" content="2021-08-29T11:36:10.270Z">
<meta property="article:author" content="BluesYoung-web">
<meta property="article:tag" content="JavaScript">
<meta property="article:tag" content="JavaScript高级程序设计第四版">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://bluesyoung-web.gitee.io/blog/img/hbs.png"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://bluesyoung-web.gitee.io/blog/2021-01-13-30-%E4%BB%A3%E7%90%86%E6%8D%95%E8%8E%B7%E5%99%A8%E4%B8%8E%E5%8F%8D%E5%B0%84%E6%96%B9%E6%B3%95"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: BluesYoung-web","link":"链接: ","source":"来源: 小黑博客","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '30-代理捕获器与反射方法',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-08-29 19:36:10'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/blog/css/background.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/HexoStaticFile@latest/Hexo/css/custom.min.css"></link><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/blog/img/hbs.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">小黑博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">30-代理捕获器与反射方法</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-01-13T03:43:53.000Z" title="发表于 2021-01-13 11:43:53">2021-01-13</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-29T11:36:10.270Z" title="更新于 2021-08-29 19:36:10">2021-08-29</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/">JavaScript高级程序设计</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1/%E7%AC%AC09%E7%AB%A0%E2%80%94%E2%80%94%E4%BB%A3%E7%90%86%E4%B8%8E%E5%8F%8D%E5%B0%84/">第09章——代理与反射</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>7分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="get-target-propName-reciver"><a href="#get-target-propName-reciver" class="headerlink" title="get(target, propName, reciver)"></a><code>get(target, propName, reciver)</code></h2><ul>
<li>参数说明：<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName</code>——‘属性名’</li>
<li><code>reciver</code>——‘调用时的对象(<code>.</code>左边的)’</li>
</ul>
</li>
<li>获取属性值时调用</li>
<li>返回值无限制</li>
<li>拦截的操作：<ul>
<li><code>proxy.property</code></li>
<li><code>proxy[property]</code></li>
<li><code>Object.create(proxy)[property]</code></li>
<li><code>Reflect.get(proxy, property, reciver)</code></li>
</ul>
</li>
<li>如果 <code>target.propName</code>不可写且不可配置，则处理程序返回的值必须与 <code>target.property</code> 匹配</li>
<li>如果 <code>target.propName</code> 不可配置且<code>[[Get]]</code>特性为 <code>undefined</code>，处理程序的返回值也必须是 <code>undefined</code></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">get</span>(<span class="params">target, property, receiver</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;get()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.get(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line">proxy.foo; </span><br><span class="line"><span class="comment">// get()</span></span><br></pre></td></tr></table></figure>

<h2 id="set-target-propName-value-reciver"><a href="#set-target-propName-value-reciver" class="headerlink" title="set(target, propName, value, reciver)"></a><code>set(target, propName, value, reciver)</code></h2><ul>
<li><p>参数说明：</p>
<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName </code>——‘属性名’</li>
<li><code>value </code>——‘属性值’</li>
<li><code>reciver </code>——‘调用时的对象(<code>.</code>左边的)’</li>
</ul>
</li>
<li><p>设置属性值时调用</p>
</li>
<li><p>返回值：</p>
<ul>
<li>成功，<code>true</code></li>
<li>失败，<code>false</code>， 严格模式抛出错误</li>
</ul>
</li>
<li><p>拦截的操作：</p>
<ul>
<li><code>proxy.property = value</code></li>
<li><code>proxy[proterty] = value </code></li>
<li><code>Object.create(proxy)[property] = value</code></li>
<li><code>Reflect.set(proxy, property, value, reciver)</code></li>
</ul>
</li>
<li><p>如果 <code>target.propName</code> 不可写且不可配置，则不能修改目标属性的值</p>
</li>
<li><p>如果 <code>target.propName</code> 不可配置且<code>[[Set]]</code>特性为 <code>undefined</code>，则不能修改目标属性的值</p>
</li>
<li><p>在严格模式下，处理程序中返回 <code>false </code>会抛出 <code>TypeError</code></p>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line">   <span class="function"><span class="title">set</span>(<span class="params">target, property, value, receiver</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;set()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.set(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line">proxy.foo = <span class="string">&#x27;bar&#x27;</span>; </span><br><span class="line"><span class="comment">// set()</span></span><br></pre></td></tr></table></figure>

<h2 id="has-target-propName"><a href="#has-target-propName" class="headerlink" title="has(target, propName)"></a><code>has(target, propName)</code></h2><ul>
<li>参数说明：<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName </code>——‘属性名’</li>
</ul>
</li>
<li><code>in</code> 操作符中调用</li>
<li>必须返回布尔值，表示属性是否存在。返回非布尔值会被转型为布尔值</li>
<li>拦截的操作：<ul>
<li><code>property in proxy</code></li>
<li><code>property in Object.create(proxy)</code></li>
<li><code>with(proxy) &#123;(property);&#125;</code></li>
<li><code>Reflect.has(proxy, property)</code></li>
</ul>
</li>
<li>如果 <code>target.propName</code> 存在且不可配置，则处理程序必须返回 <code>true</code></li>
<li>如果<code> target.propName</code> 存在且目标对象不可扩展，则处理程序必须返回 <code>true</code></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">has</span>(<span class="params">target, property</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;has()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.has(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="string">&#x27;foo&#x27;</span> <span class="keyword">in</span> proxy; </span><br><span class="line"><span class="comment">// has()</span></span><br></pre></td></tr></table></figure>

<h2 id="defineProperty-target-propName-configObj"><a href="#defineProperty-target-propName-configObj" class="headerlink" title="defineProperty(target, propName, configObj)"></a><code>defineProperty(target, propName, configObj)</code></h2><ul>
<li>参数说明：<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName </code>——‘属性名’</li>
<li><code>configObj</code>——‘属性配置对象’</li>
</ul>
</li>
<li>在 <code>Object.defineProperty()</code>中被调用</li>
<li>必须返回布尔值，表示属性定义是否成功，返回其他的值会被<strong>自动转换为布尔值</strong></li>
<li>拦截的操作：<ul>
<li><code>Object.defineProperty(proxy, property, descriptor)</code></li>
<li><code>Reflect.defineProperty(proxy, property, descriptor)</code></li>
</ul>
</li>
<li>如果目标对象不可扩展，则无法定义属性</li>
<li>如果目标对象有一个可配置的属性，则不能添加同名的不可配置属性</li>
<li>如果目标对象有一个不可配置的属性，则不能添加同名的可配置属性</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">defineProperty</span>(<span class="params">target, property, descriptor</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;defineProperty()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.defineProperty(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.defineProperty(proxy, <span class="string">&#x27;foo&#x27;</span>, &#123; <span class="attr">value</span>: <span class="string">&#x27;bar&#x27;</span> &#125;); </span><br><span class="line"><span class="comment">// defineProperty()</span></span><br></pre></td></tr></table></figure>

<h2 id="getOwnPropertyDescriptor-target-propName"><a href="#getOwnPropertyDescriptor-target-propName" class="headerlink" title="getOwnPropertyDescriptor(target, propName)"></a><code>getOwnPropertyDescriptor(target, propName)</code></h2><ul>
<li>参数说明：<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName </code>——‘属性名’</li>
</ul>
</li>
<li>会在 <code>Object.getOwnPropertyDescriptor()</code> 中被调用</li>
<li>必须返回对象，或者在属性不存在时返回 <code>undefined</code></li>
<li>拦截的操作：<ul>
<li><code>Object.getOwnPropertyDescriptor(proxy, property)</code></li>
<li><code>Reflect.getOwnPropertyDescriptor(proxy, property)</code></li>
</ul>
</li>
<li>如果自有的 <code>target.propName</code> 存在且不可配置，则处理程序必须返回一个表示该属性存在的对象</li>
<li>如果自有的 <code>target.propName</code> 存在且可配置，则处理程序必须返回表示该属性可配置的对象</li>
<li>如果自有的 <code>target.propName</code> 存在且 <code>target</code> 不可扩展，则处理程序必须返回一个表示该属性存在的对象</li>
<li>如果 <code>target.propName</code> 不存在且 <code>target</code> 不可扩展，则处理程序必须返回 <code>undefined</code> 表示该属性不存在</li>
<li>如果 <code>target.propName</code> 不存在，则处理程序不能返回表示该属性可配置的对象</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">getOwnPropertyDescriptor</span>(<span class="params">target, property</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;getOwnPropertyDescriptor()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.getOwnPropertyDescriptor(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.getOwnPropertyDescriptor(proxy, <span class="string">&#x27;foo&#x27;</span>); </span><br><span class="line"><span class="comment">// getOwnPropertyDescriptor()</span></span><br></pre></td></tr></table></figure>

<h2 id="deleteProperty-target-propName"><a href="#deleteProperty-target-propName" class="headerlink" title="deleteProperty(target, propName)"></a><code>deleteProperty(target, propName)</code></h2><ul>
<li><p>参数说明：</p>
<ul>
<li><code>target</code>——‘原始对象’</li>
<li><code>propName </code>——‘属性名’</li>
</ul>
</li>
<li><p>在 <code>delete </code>操作符中被调用</p>
</li>
<li><p>必须返回布尔值，表示属性定义是否成功，返回其他的值会被<strong>自动转换为布尔值</strong></p>
</li>
<li><p>拦截的操作：</p>
<ul>
<li><code>delete proxy.property</code></li>
<li><code>delete proxy[property]</code></li>
<li><code>Reflect.deleteProperty(proxy, property)</code></li>
</ul>
</li>
<li><p>如果自有的 <code>target.property </code>存在且不可配置，则处理程序不能删除这个属性</p>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">deleteProperty</span>(<span class="params">target, property</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;deleteProperty()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.deleteProperty(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="keyword">delete</span> proxy.foo </span><br><span class="line"><span class="comment">// deleteProperty()</span></span><br></pre></td></tr></table></figure>

<h2 id="ownKeys-target"><a href="#ownKeys-target" class="headerlink" title="ownKeys(target)"></a><code>ownKeys(target)</code></h2><ul>
<li>在<code> Object.keys()</code>及类似方法中被调用</li>
<li>必须返回包含字符串或符号的可枚举对象</li>
<li>拦截的操作：<ul>
<li><code>Object.getOwnPropertyNames(proxy)</code></li>
<li><code>Object.getOwnPropertySymbols(proxy)</code></li>
<li><code>Object.keys(proxy)</code></li>
<li><code>Reflect.ownKeys(proxy)</code></li>
</ul>
</li>
<li>返回的可枚举对象必须包含 <code>target </code>的所有不可配置的自有属性</li>
<li>如果 <code>target </code>不可扩展，则返回可枚举对象必须准确地包含自有属性键</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line">   <span class="function"><span class="title">ownKeys</span>(<span class="params">target</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;ownKeys()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.ownKeys(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.keys(proxy); </span><br><span class="line"><span class="comment">// ownKeys()</span></span><br></pre></td></tr></table></figure>

<h2 id="getPrototypeOf-target"><a href="#getPrototypeOf-target" class="headerlink" title="getPrototypeOf(target)"></a><code>getPrototypeOf(target)</code></h2><ul>
<li>在 <code>Object.getPrototypeOf()</code>中被调用</li>
<li>必须返回对象或 <code>null</code></li>
<li>拦截的操作：<ul>
<li><code>Object.getPrototypeOf(proxy)</code></li>
<li><code>Reflect.getPrototypeOf(proxy)</code></li>
<li><code>proxy.__proto__</code></li>
<li><code>Object.prototype.isPrototypeOf(proxy)</code></li>
<li><code>proxy instanceof Object</code></li>
</ul>
</li>
<li>如果 <code>target </code>不可扩展，则 <code>Object.getPrototypeOf(proxy)</code>唯一有效的返回值就是 <code>Object.getPrototypeOf(target)</code>的返回值</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">getPrototypeOf</span>(<span class="params">target</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;getPrototypeOf()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.getPrototypeOf(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.getPrototypeOf(proxy); </span><br><span class="line"><span class="comment">// getPrototypeOf()</span></span><br></pre></td></tr></table></figure>

<h2 id="setPrototypeOf-target-prototype"><a href="#setPrototypeOf-target-prototype" class="headerlink" title="setPrototypeOf(target, prototype)"></a><code>setPrototypeOf(target, prototype)</code></h2><ul>
<li>在 <code>Object.setPrototypeOf()</code>中被调用</li>
<li>必须返回布尔值，表示原型赋值是否成功。返回非布尔值会被转型为布尔值</li>
<li>拦截的操作：<ul>
<li><code>Object.setPrototypeOf(proxy)</code></li>
<li><code>Reflect.setPrototypeOf(proxy)</code></li>
</ul>
</li>
<li>如果 <code>target </code>不可扩展，则唯一有效的 <code>prototype </code>参数就是 <code>Object.getPrototypeOf(target)</code>的返回值</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">setPrototypeOf</span>(<span class="params">target, prototype</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;setPrototypeOf()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.setPrototypeOf(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.setPrototypeOf(proxy, <span class="built_in">Object</span>); </span><br><span class="line"><span class="comment">// setPrototypeOf()</span></span><br></pre></td></tr></table></figure>

<h2 id="isExtensible-target"><a href="#isExtensible-target" class="headerlink" title="isExtensible(target)"></a><code>isExtensible(target)</code></h2><ul>
<li>在 <code>Object.isExtensible()</code>中被调用</li>
<li>必须返回布尔值，表示 <code>target </code>是否可扩展。返回非布尔值会被转型为布尔值</li>
<li>拦截的操作：<ul>
<li><code>Object.isExtensible(proxy)</code></li>
<li><code>Reflect.isExtensible(proxy)</code></li>
</ul>
</li>
<li>如果 <code>target </code>可扩展，则处理程序必须返回 <code>true</code></li>
<li>如果 <code>target </code>不可扩展，则处理程序必须返回 <code>false</code></li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">isExtensible</span>(<span class="params">target</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;isExtensible()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.isExtensible(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.isExtensible(proxy); </span><br><span class="line"><span class="comment">// isExtensible()</span></span><br></pre></td></tr></table></figure>

<h2 id="preventExtensions-target"><a href="#preventExtensions-target" class="headerlink" title="preventExtensions(target)"></a><code>preventExtensions(target)</code></h2><ul>
<li><p>在 <code>Object.preventExtensions()</code>中被调用</p>
</li>
<li><p>必须返回布尔值，表示 <code>target </code>是否<strong>已经不可扩展</strong>，返回非布尔值会被转换为布尔值</p>
</li>
<li><p>拦截的操作：</p>
<ul>
<li><code>Object.preventExtensions(proxy)</code></li>
<li><code>Reflect.preventExtensions(proxy)</code></li>
</ul>
</li>
<li><p>如果<code> Object.isExtensible(proxy)</code>是 <code>false</code>，则处理程序必须返回 <code>true</code></p>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> myTarget = &#123;&#125;; </span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="built_in">Proxy</span>(myTarget, &#123; </span><br><span class="line"> <span class="function"><span class="title">preventExtensions</span>(<span class="params">target</span>)</span> &#123; </span><br><span class="line">   <span class="built_in">console</span>.log(<span class="string">&#x27;preventExtensions()&#x27;</span>); </span><br><span class="line">   <span class="keyword">return</span> <span class="built_in">Reflect</span>.preventExtensions(...arguments) </span><br><span class="line"> &#125; </span><br><span class="line">&#125;); </span><br><span class="line"><span class="built_in">Object</span>.preventExtensions(proxy); </span><br><span class="line"><span class="comment">// preventExtensions()</span></span><br></pre></td></tr></table></figure>

<h2 id="apply-target-thisObj-argsList"><a href="#apply-target-thisObj-argsList" class="headerlink" title="apply(target, thisObj, ...argsList)"></a><code>apply(target, thisObj, ...argsList)</code></h2><ul>
<li>参数解释：<ul>
<li><code>target</code>——‘目标对象’</li>
<li><code>thisObj</code>——‘this指向的对象’</li>
<li><code>argsList</code>——‘调用函数时的参数列表’</li>
</ul>
</li>
<li>在调用函数时被调用</li>
<li>返回值无限制</li>
<li>拦截的操作：<ul>
<li><code>proxy(...argumentsList)</code></li>
<li><code>Function.prototype.apply(thisArg, argumentsList)</code></li>
<li><code>Function.prototype.call(thisArg, ...argumentsList)</code></li>
<li><code>Reflect.apply(target, thisArgument, argumentsList)</code></li>
</ul>
</li>
<li><code>target </code>必须是一个函数对象</li>
</ul>
<h2 id="construct-target-argsList-newTarget"><a href="#construct-target-argsList-newTarget" class="headerlink" title="construct(target, argsList, newTarget)"></a><code>construct(target, argsList, newTarget)</code></h2><ul>
<li>参数解释：<ul>
<li><code>target</code>——‘目标构造函数’</li>
<li><code>argsList</code>——‘传给目标构造函数的参数列表’</li>
<li><code>newTarget</code>——‘最初被调用的构造函数’</li>
</ul>
</li>
<li>必须返回一个对象</li>
<li><code>target</code> 必须可以用作构造函数</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">BluesYoung-web</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://bluesyoung-web.gitee.io/blog/2021-01-13-30-%E4%BB%A3%E7%90%86%E6%8D%95%E8%8E%B7%E5%99%A8%E4%B8%8E%E5%8F%8D%E5%B0%84%E6%96%B9%E6%B3%95.html">https://bluesyoung-web.gitee.io/blog/2021-01-13-30-%E4%BB%A3%E7%90%86%E6%8D%95%E8%8E%B7%E5%99%A8%E4%B8%8E%E5%8F%8D%E5%B0%84%E6%96%B9%E6%B3%95.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://BluesYoung-web.gitee.io/blog" target="_blank">小黑博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/JavaScript/">JavaScript</a><a class="post-meta__tags" href="/blog/tags/JavaScript%E9%AB%98%E7%BA%A7%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AC%AC%E5%9B%9B%E7%89%88/">JavaScript高级程序设计第四版</a></div><div class="post_share"></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/blog/img/wx.png" target="_blank"><img class="post-qr-code-img" src="/blog/img/wx.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/blog/img/zfb.jpg" target="_blank"><img class="post-qr-code-img" src="/blog/img/zfb.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/2020-12-28-01-历史回顾.html" title="01-历史回顾"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">01-历史回顾</div></div></a></div><div><a href="/blog/2020-12-28-03-script元素.html" title="03-script元素"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">03-script元素</div></div></a></div><div><a href="/blog/2020-12-28-02-实现.html" title="02-实现"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">02-实现</div></div></a></div><div><a href="/blog/2020-12-28-04-文档模式.html" title="04-文档模式"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">04-文档模式</div></div></a></div><div><a href="/blog/2020-12-28-05-语法.html" title="05-语法"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">05-语法</div></div></a></div><div><a href="/blog/2020-12-28-06-变量声明.html" title="06-变量声明"><img class="cover" src="/blog/img/hbs.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-12-28</div><div class="title">06-变量声明</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">BluesYoung-web</div><div class="author-info__description">一枚不善言辞的技术宅</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="card-info-data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="card-info-data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/BluesYoung-web"><i class="fab fa-gitee"></i><span>点个小星星吧</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/BluesYoung-web" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:15171255945@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="移动端软键盘导致布局错乱"/></a><div class="content"><a class="title" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱">移动端软键盘导致布局错乱</a><time datetime="2021-08-24T10:01:20.000Z" title="发表于 2021-08-24 18:01:20">2021-08-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux安装you-get"/></a><div class="content"><a class="title" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get">Linux安装you-get</a><time datetime="2021-08-16T08:07:31.000Z" title="发表于 2021-08-16 16:07:31">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="git删除远程仓库的提交"/></a><div class="content"><a class="title" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交">git删除远程仓库的提交</a><time datetime="2021-08-16T07:52:02.000Z" title="发表于 2021-08-16 15:52:02">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="将pad扩展为电脑的副屏"/></a><div class="content"><a class="title" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏">将pad扩展为电脑的副屏</a><time datetime="2021-08-13T11:44:04.000Z" title="发表于 2021-08-13 19:44:04">2021-08-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux启用SSH服务"/></a><div class="content"><a class="title" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务">Linux启用SSH服务</a><time datetime="2021-08-11T10:50:04.000Z" title="发表于 2021-08-11 18:50:04">2021-08-11</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By BluesYoung-web</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/blog/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script> <script src="/blog/js/xkTool.js"></script> <script src="/blog/js/mySelf.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script></div></body></html>